package easy;

import java.util.ArrayList;
import java.util.List;

public class Solution_225 {

    public static void main(String[] args) {
        MyStack obj = new MyStack();
        obj.push(1);
        int param_2 = obj.pop();
//        obj.push(2);
//        obj.push(3);
        obj.push(4);
        int param_3 = obj.top();
        boolean param_4 = obj.empty();
        System.out.println(param_2);
        System.out.println(param_3);
        System.out.println(param_4);
    }
}

class MyStack {

    private Integer top = -1;
    private List<Integer> list;

    /** Initialize your data structure here. */
    public MyStack() {
        list = new ArrayList<>();
    }

    /** Push element x onto stack. */
    public void push(int x) {
        if (list.size()==(top+1)) {
            list.add(x);
        } else {
            list.add(top+1, x);
        }
        top++;
    }

    /** Removes the element on top of the stack and returns that element. */
    public int pop() {
        Integer val = list.get(top);
        top--;
        return val;
    }

    /** Get the top element. */
    public int top() {
        return list.get(top);
    }

    /** Returns whether the stack is empty. */
    public boolean empty() {
        return top==-1;
    }
}
